package com.mdlib.droid.module.home.adapter;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mdlib.droid.R;
import com.mdlib.droid.model.entity.MyEntity;

import java.util.List;

/**
 * 作者：HQY on 2018/10/24 11:39
 * 邮箱：hqy_xz@126.com
 */

public class MyAdapter extends BaseQuickAdapter<MyEntity, BaseViewHolder> {

    public MyAdapter(List<MyEntity> data) {
        super(R.layout.item_my, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyEntity item) {

        ImageView ivGo = helper.getView(R.id.iv_my_go);
        TextView tvCache = helper.getView(R.id.tv_my_cache);
        TextView tvNmae = helper.getView(R.id.tv_my_name);

        Drawable drawable = mContext.getResources().getDrawable(item.getResId());
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        tvNmae.setCompoundDrawables(drawable, null, null, null);
        tvNmae.setText(item.getName());
        if (helper.getAdapterPosition() == 5) {
            tvCache.setVisibility(View.VISIBLE);
            ivGo.setVisibility(View.GONE);
            tvCache.setText(item.getCache());
        } else {
            tvCache.setVisibility(View.GONE);
            ivGo.setVisibility(View.VISIBLE);
        }

    }
}
